

#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import "Reachability.h"
#import "GConfig.h"
#import "iToast.h"
#import "PBArray.h"
#import "User.pb.h"

#define NetWorkConnected                                ([GToolUtil sharedInstance].netAvailable)

#define ERROR_WITH_TYPE_AND_CODE_AND_USERINFO(type, ecode, userinfo) ([NSError errorWithDomain: ([NSString stringWithFormat:@"fp_%d", (type)]) code:(ecode) userInfo: (userinfo)])
#define ERROR_WITH_TYPE_AND_CODE(type, code) ERROR_WITH_TYPE_AND_CODE_AND_USERINFO(type, code, nil)
#define ERROR_WITH_TYPE_AND_CODE_AND_MESSAGE(type, code, msg) ERROR_WITH_TYPE_AND_CODE_AND_USERINFO(type, code, ([NSDictionary dictionaryWithObjectsAndKeys:(msg), @"message", nil]))

#define L2S(num)        [NSString stringWithFormat:@"%lld", (num)]
#define I2S(num)        [NSString stringWithFormat:@"%d", (num)]

@interface GToolUtil : NSObject {
    
    Reachability *          _reachability;
    
}

@property BOOL                                      netAvailable;
@property (nonatomic, retain) NSString *            netType;
@property (nonatomic, retain) NSString *            netStatus;
@property (nonatomic, retain) NSDateFormatter *     dateFormatter;

+ (GToolUtil*) sharedInstance;

+(NSString*)urlEscape:(NSString *)unencodedString;
+(NSString*)urlUnescape: (NSString *)input;
+(NSString*)addQueryStringToUrl:(NSString *)url params:(NSDictionary *)params;

+(NSString*)dateStrFromDataFormat:(long long)time;
+(NSString*)dateStrFromDataFormat2:(long long)time;

+ (BOOL)isMobileNumber:(NSString *)mobileNum;

+ (long long)NSDateToFPDate:(NSDate*)date;

+ (NSMutableArray*)PBArr2NSArr:(PBArray*)array;

+ (UserMessage*)ownerMsg;

+ (NSString*) stringBySeconds:(NSInteger)seconds;

@end
